#pragma once
#include "Object.h"
#include <d3dx9.h>
#include "GameDefine.h"
class Box;
class Arm;

class Arm :
	public Object
{
	
public:
	D3DXVECTOR2 _centerPoint;
	float angle;
	float _radius;
	Arm* _next;
	Arm* _parent;
	float _k;
	float _omega;
	float _min, _max;
	ArmState _state;
	int token;
	int tokenId;
	bool _isParent;
	Arm(D3DXVECTOR2 _tam, float r, float pi,float v,float min, float max);
	~Arm(void);

	virtual void init();

	virtual void update();

	virtual void render();

	virtual Box* getCollisionBox();

	void increaseAngle()
	{
		if( angle <= _min)
		{
			_k = 1.0f;
			token = 2;
		}
		if(angle >= _max )
		{
			_k = -1.0f;
			token = 2;
		}
		angle += _omega * _k;
	}

	void addNext(Arm* arm);

	float getAngle();

	Arm* getNext();

	void setAngle(float a);

	void wave(float _angle, float _direct, int& _turn);

	void follow(float _angle);

	void rotate(float _angle, float _direct);

	void kill();
	void _setPosition(D3DXVECTOR2 pos);
};

